import { DataTypes, Optional } from "sequelize";
import { Table, Column, Model, AllowNull, AutoIncrement, PrimaryKey, Comment, Unique, CreatedAt, UpdatedAt, DeletedAt, DataType, NotEmpty } from 'sequelize-typescript'

export interface LogAttributes {
    id?: number;
    createdAt?: Date;
    updatedAt?: Date;
    deletionDate?: Date;
    requestName?: string;
    requestType?: string;
    requestHeaders?: string;
    responseHeaders?: string;
    requestData?: string;
    requestPath?: string;
    responseData?: string;
    requestHost?: string;
    requestIp?: string;
    error?: string;
}
export interface LogCreationAttributes extends Optional<LogAttributes, 'id'> { }
@Table({
    tableName: 'log'
})
export default class Log extends Model<LogAttributes, LogCreationAttributes> {

    @Comment('主键id')
    @AllowNull(false)
    @NotEmpty
    @AutoIncrement
    @PrimaryKey
    @Column({
        type: DataType.INTEGER
    })
    id?: number;

    @Comment('创建时间')
    @CreatedAt
    @Column({
        type: DataType.DATE
    })
    createdAt?: Date;

    @Comment('更新时间')
    @UpdatedAt
    @Column({
        type: DataType.DATE
    })
    updatedAt?: Date;

    @Comment('删除时间')
    @DeletedAt
    @Column({
        type: DataType.DATE
    })
    deletionDate?: Date;

    @Comment('接口名称')
    @Column({
        type: DataType.STRING
    })
    requestName?: string;

    @Comment('请求类型')
    @Column({
        type: DataType.TEXT
    })
    requestType?: string;

    @Comment('请求头')
    @Column({
        type: DataType.TEXT
    })
    requestHeaders?: string;

    @Comment('响应头')
    @Column({
        type: DataType.TEXT
    })
    responseHeaders?: string;

    @Comment('请求参数')
    @Column({
        type: DataType.TEXT
    })
    requestData?: string;

    @Comment('请求路径')
    @Column({
        type: DataType.STRING
    })
    requestPath?: string;

    @Comment('响应结果')
    @Column({
        type: DataType.TEXT
    })
    responseData?: string;

    @Comment('请求主机')
    @Column({
        type: DataType.STRING
    })
    requestHost?: string;

    @Comment('请求IP')
    @Column({
        type: DataType.STRING
    })
    requestIp?: string;

    @Comment('错误报文')
    @Column({
        type: DataType.TEXT
    })
    error?: string;

}